package com.boot.security.server.dict.controller;

import com.boot.security.server.common.Result;
import com.boot.security.server.dict.model.DataDict;
import com.boot.security.server.dict.model.LayUiModel;
import com.boot.security.server.dict.service.IDictService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * 字典
 * @author Administrator
 */
@SuppressWarnings("ALL")
@RestController
@RequestMapping("/dataDict")
public class DataDictController {

    @Autowired
    private IDictService dictService;

    @PostMapping("/findAll")
    @ApiOperation(value = "查询数据字典")
    @ResponseBody
    public LayUiModel findAll (HttpServletRequest request) {
        return dictService.findAllPage(request);
    }

    @GetMapping("/findById/{id}")
    @ApiOperation(value = "查询数据字典-编辑")
    @ResponseBody
    public LayUiModel findById (@PathVariable Integer id) {
        return dictService.findById(id);
    }

    @PostMapping("/add")
    @ApiOperation(value = "添加数据字典")
    public Result add(@RequestBody DataDict dataDict) {
        return dictService.add(dataDict);
    }

    @PostMapping("/update")
    @ApiOperation(value = "数据字典-编辑")
    @ResponseBody
    public Result updateDict(@RequestBody DataDict dataDict) {
        return dictService.update(dataDict);
    }

    @DeleteMapping("/delete/{id}")
    @ApiOperation(value = "删除数据字典")
    public Result delDict(@PathVariable Integer id) {
        return dictService.delete(id);
    }

}
